package net.brucecooper.mindmap.client;

import gwt.canvas.client.Canvas;

import com.google.gwt.user.client.ui.Widget;

public abstract class GraphicComponent {
    protected int width;
    protected int height;
    protected int x;
    protected int y;
    protected GraphicComponent parent;
	private boolean tooltipEnabled;



    public Point getRootCoordinates(Point pt) {
        if (parent == null) {
            return pt;
        } else {
            return parent.getRootCoordinates(new Point(pt.x + x, pt.y + y));

        }
    }

    public abstract GraphicComponent getWidget(int index);
    public abstract int getWidgetCount();
    public abstract void add(int index, GraphicComponent comp);
    public abstract  void add(GraphicComponent comp);
    public abstract  boolean remove(GraphicComponent comp);
    public abstract  void remove(int index);
    public abstract  int getWidgetIndex(GraphicComponent comp);
    public abstract void paint(Canvas canvas, Clip clip);
    public abstract void layout(Canvas canvas);
    public abstract int getPreferredHeight(Canvas canvas);
    public abstract GraphicComponent findDeepest(int x, int y);
    public abstract int getPreferredWidth(Canvas canvas);
    
    
    public void paintComponent(Canvas canvas, Clip clip) {
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public void setBounds(int x, int y, int w, int h) {
        this.x = x;
        this.y = y;
        this.width = w;
        this.height = h;
    }

    public GraphicComponent getParent() {
        return parent;
    }


    public boolean isTooltipEnabled() {
    	return tooltipEnabled;
    }
    
    public void setTooltipEnabled(boolean tooltipEnabled) {
    	this.tooltipEnabled = tooltipEnabled;
    }
    
    public Widget getTooltip() {
    	return null;
    }
}
